package com.niuke;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

/**
 * 17. 叠积木
 * https://blog.csdn.net/m0_46181452/article/details/131666554
 */
public class NiukeMoni18 {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        String[] input = scanner.nextLine().split(" ");

        Map<Integer, Integer> counts = new LinkedHashMap<>();
        for (int i = 0; i < input.length; i++) {
            Integer key = Integer.parseInt(input[i]);
            counts.put(key, counts.getOrDefault(key, 0) + 1);
        }

        // --------------------------------------------------------
        int n = 0;
        if (counts.size() == 1) {
            n = counts.get(Integer.parseInt(input[0]));
        } else {
            List<Integer> keys = new ArrayList<>(counts.keySet());
            System.out.println(Arrays.toString(keys.toArray()));

            // 先试下长度一层长度最小，也就是长度最长的那个积木长度能不能产生结果n，可以的话直接返回
            int length = keys.get(keys.size() - 1);
            Set<Integer> jump = new HashSet<>();
            for (int i = 0; i < keys.size(); i++) {
                Integer key = keys.get(i);
                if (jump.contains(key)) {
                    continue;
                }
                if (key * 2 == length) {
                    if (counts.get(key) % 2 == 0) {
                        n += counts.get(key) / 2;
                    } else {
                        n = 0;
                        jump.clear();
                        break;
                    }
                } else if (key == length) {
                    n += counts.get(key);
                } else {
                    if (counts.containsKey(length - key) && counts.get(key) == counts.get(length - key)) {
                        n += counts.get(key);
                        jump.add(length - key);
                    } else {
                        n = 0;
                        jump.clear();
                        break;
                    }
                }
            }

            // 没产生最优解，要尝试改变length
            if (n == 0) {
                if (input.length % 2 != 0) {
                    return;
                }
                for (int i = 0; i < keys.size() - 1; i++) {
                    for (int j = i + 1; j < keys.size(); j++) {
                        length = keys.get(i) + keys.get(j);
                        if (length <= keys.get(keys.size() - 1)) {
                            continue;
                        }

                        int tempN = 0;
                        for (int k = 0; k < keys.size(); k++) {
                            Integer key = keys.get(k);
                            if (jump.contains(key)) {
                                continue;
                            }
                            if (key * 2 == length) {
                                if (counts.get(key) % 2 == 0) {
                                    tempN += counts.get(key) / 2;
                                } else {
                                    tempN = 0;
                                    jump.clear();
                                    break;
                                }
                            } else {
                                if (counts.containsKey(length - key) && counts.get(key) == counts.get(length - key)) {
                                    tempN += counts.get(key);
                                    jump.add(length - key);
                                } else {
                                    tempN = 0;
                                    jump.clear();
                                    break;
                                }
                            }
                        }

                        if (tempN != 0) {
                            n = Math.max(n, tempN);
                            jump.clear();
                        }
                    }
                }
            }
        }

        if (n == 0) {
            System.out.println("-1");
        } else {
            System.out.println(n);
        }
    }

}
